<template>
	<view class="content">
	<!-- <button @click="scanCode">扫描</button> -->
	<!-- uniapp 自带的不兼容H5 -->
	<!-- <i class="iconfont icon-saomiao" style="color:#1296db;font-size: 90rpx;" @click="scanCode" ></i> -->
	<!-- 一维码 -->
	<view class="">
		{{result}}
	</view>
	<view class="" style="margin: 20rpx 0;">
		<img src="../../static/code.png" style="width: 400rpx;height: 100rpx;" alt="">
	</view>
	 <i class="iconfont icon-saomiao" style="color:#1296db;font-size: 90rpx;" @click="scanCode" ></i>
	</view>
</template>

<script>
	import {
		Buffer
	} from 'buffer';
	// import jzH5ScanCode from '../../node_modules/jz-h5-scanCode/uni_modules/jz-h5-scanCode/js/index.js'
	export default {
		data() {
			return {
				// title: 'Hello',
				result: '',
				// html5Qrcode: null,
				// cameraId:null
			}
		},
		onLoad() {},
		methods: {
			scanCode() {
				uni.scanCode({
					onlyFromCamera: true,
					success: function(res) {
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
						// const result = res.result
						// const url = Buffer.from(result, "base64").toString()
						// 小程序不能直接跳转外部 需要web-view跳转
						// uni.navigateTo({
						// 	url: '/pages/index/web?url=' + url
						// })
					}
				});
			},
			// h5扫码
			h5Code() {
				// 基础扫码 h5
				// jzH5ScanCode.scanCode({
				//     success: (res) => {
				//         console.log('扫码成功:', res.result)
				// 		this.result=res.result
				//     },
				//     fail: (res) => {
				//         console.log('扫码失败:', res.errMsg)
				//     }
				// })
			},
		}
	}
</script>

<style lang="scss" scoped>
	.code-box {
		margin: 20rpx 0;
		display: flex;
		justify-content: center;
	}
</style>